<template>
  <div class="asider">
    <el-menu
      router
    >
      <!-- 员工管理 -->
      <el-menu-item index="/employee" :disabled="!isAdministrator">
        <i class="iconfont icon-yuangong"></i>
        <span slot="title">员工管理</span>
      </el-menu-item>
      <!-- 货源管理 -->
      <el-submenu index="/goodsResource" :disabled="!isAdministrator">
        <template slot="title">
          <i class="iconfont icon-huoyuan"></i>
          <span>货源管理</span>
        </template>
        <el-menu-item-group>
          <el-menu-item index="/supplier">
            <i class="iconfont icon-gongyingshang"></i>
            供应商
          </el-menu-item>
          <el-menu-item index="/warehouse">
            <i class="iconfont icon-cangku"></i>
            仓库
          </el-menu-item>
        </el-menu-item-group>
      </el-submenu>
      <!-- 药品管理 -->
      <el-submenu index="/medicine" :disabled="!isAdministrator">
        <template slot="title">
          <i class="iconfont icon-yaopin"></i>
          <span>药品管理</span>
        </template>
        <el-menu-item-group>
          <el-menu-item index="/medicineType">
            <i class="iconfont icon-icon"></i>
            药品类别
          </el-menu-item>
          <el-menu-item index="/medicine">
            <i class="iconfont icon-xinxi"></i>
            药品信息
          </el-menu-item>
        </el-menu-item-group>
      </el-submenu>
      <!-- 采购管理 -->
      <el-submenu index="/procurement" :disabled="isAdministrator">
        <template slot="title">
          <i class="iconfont icon-jinhuo"></i>
          <span>采购管理</span>
        </template>
        <el-menu-item-group>
          <el-menu-item index="/purchase">
            <i class="iconfont icon-a-jinhuodaoru"></i>
            采购
          </el-menu-item>
          <el-menu-item index="/procurement">
            <i class="iconfont icon-jinhuodan"></i>
            采购列表
          </el-menu-item>
        </el-menu-item-group>
      </el-submenu>
      <!-- 出库管理 -->
      <el-submenu index="/deliver" :disabled="isAdministrator">
        <template slot="title">
          <i class="iconfont icon-chuhuo"></i>
          <span>出库管理</span>
        </template>
        <el-menu-item-group>
          <el-menu-item index="/inventory">
            <i class="iconfont icon-chakankucun"></i>
            库存
          </el-menu-item>
          <el-menu-item index="/deliver">
            <i class="iconfont icon-tubiaozhizuomoban-76"></i>
            出库列表
          </el-menu-item>
        </el-menu-item-group>
      </el-submenu>
      <!-- 数据统计 -->
      <el-menu-item index="/statistic">
        <i class="iconfont icon-shujubaobiao"></i>
        <span slot="title">数据统计</span>
      </el-menu-item>
    </el-menu>
  </div>
</template>

<script>

export default {
  name: 'Asider',
  data() {
    return {
      /* 判断是否为管理员 */
      isAdministrator: true,
    }
  },
  methods: {
    /* 获得权限 */
    async getPrivilege() {
      let user = JSON.parse(window.localStorage.getItem('user'))
      const { data: res } = await this.$http.post('settings/administrator/getPrivilege.do',{
        currentUserId: user.id
      })
      if (res.code == '1') {
        this.isAdministrator = res.others
      } else {
          console.log('判断当前权限失败!')
      }
    }
  },
  created() {
    this.getPrivilege()
  }
}
</script>

<style scoped>
.asider {
  height: 100%;
}
.el-menu {
  font-size: 18px;
  height: 100%;
}
.iconfont {
  font-size: 18px;
  margin-right: 6px;
}
</style>
